package com.bg8loo.amateur.handler;


import org.springframework.boot.web.error.ErrorAttributeOptions;
import org.springframework.boot.web.servlet.error.DefaultErrorAttributes;
import org.springframework.stereotype.Component;
import org.springframework.web.context.request.WebRequest;

import java.util.Map;

@Component
public class MyErrorAttributes  extends DefaultErrorAttributes {

//    访问4xx或者5xx回显 static/error
    @Override
    public Map<String, Object> getErrorAttributes(WebRequest webRequest, ErrorAttributeOptions options) {
        Map<String, Object> map = super.getErrorAttributes(webRequest, options);
//        if ((Integer) map.get("status") == 500) {
//            map.put("message", "服务器内部错误!");
//        }
        return map;
    }
}
